<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>美化表单示例</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            background-color: #f0f8ff;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            margin: 0;
        }

        .form-container {
            background-color: #ffffff;
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
            width: 300px;
        }

        .form-group {
            margin-bottom: 15px;
        }

        .form-group label {
            display: block;
            margin-bottom: 5px;
            font-weight: bold;
        }

        .form-group input {
            width: 100%;
            padding: 8px;
            box-sizing: border-box;
            border: 1px solid #ccc;
            border-radius: 4px;
        }
        .form-group textarea {
            width: 100%;
            padding: 8px;
            box-sizing: border-box;
            border: 1px solid #ccc;
            border-radius: 4px;
        }

        .form-group button {
            width: 100%;
            padding: 10px;
            background-color: #007bff;
            color: #ffffff;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            font-size: 16px;
            transition: background-color 0.3s ease;
        }

        .form-group button:hover {
            background-color: #0056b3;
        }
    </style>
</head>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script>
    $(document).ready(function() {
        $('#form').submit(function(event) {
            event.preventDefault();
            var title = $('#title').val();
            var content = $('#content').val();
            $.ajax({
                url: '/message/addMessage',
                type: 'POST',
                data: {
                    title: title,
                    content: content
                },
                success: function(response) {
                    if (response.code == 200) {
                        alert('留言成功');
                        window.location.href = 'user_index.html';
                    } else {
                        alert('留言失败');
                    }
                }
            })
        });
    });
</script>
<body>

<div class="form-container">
    <form action="" id="form">
        <div class="form-group">
            <label for="title">标题</label>
            <input type="text" id="title" name="title">
        </div>
        <div class="form-group">
            <label for="content">内容</label>
            <textarea type="text" id="content" name="content" rows="6"></textarea>
        </div>
        <div class="form-group">
            <button type="submit">确定</button>
        </div>
    </form>
</div>

</body>
</html>